package com.randi.web.controller.system;

import com.randi.common.config.AppConfig;
import com.randi.common.core.domain.Result;
import com.randi.common.utils.StringUtils;
import com.randi.system.service.ISysIndexService;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/")
@Api(value = "SysIndexController", tags = "首页管理")
public class SysIndexController {

    @Resource
    private AppConfig appConfig;

    @Resource
    private ISysIndexService iSysIndexService;

    @GetMapping
    public String index() {
        String name = appConfig.getName();
        String version = appConfig.getVersion();
        return StringUtils.format("欢迎使用{}后台管理框架，当前版本：v{}，请通过前端地址访问。", name, version);
    }

    @GetMapping("/info")
    public Result getInfo() {
        return Result.success().put(iSysIndexService.getInfo());
    }

}
